<f:view contentType="text/html" xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:s="http://jboss.org/schema/seam/taglib">
  <s:fragment
    rendered="#{not empty applicationConfiguration.piwikUrl and not empty applicationConfiguration.piwikIdSite}">
    <!-- Piwik -->
    <script type="text/javascript">
      //<![CDATA[remove any trailing slash
      function stripTrailingSlash(url) {
        return url.replace(/\/$/, "");
      }

      //if url doesn't contain protocol, append to it
      function checkProtocol(url) {
        var protocol = "";

        if ((url.indexOf("http") == -1) && (url.indexOf("https") == -1)) {
          protocol =
            (("https:" == document.location.protocol) ? "https://" : "http://");
        }
        return stripTrailingSlash(protocol + url);
      }

      var pkBaseURL = checkProtocol("#{applicationConfiguration.piwikUrl}") +
        "/";

      document.write(unescape("%3Cscript src='" + pkBaseURL +
        "piwik.js' type='text/javascript'%3E%3C/script%3E"));
      //]]>
    </script>
    <script type="text/javascript">//<![CDATA[
    try {
      var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php",
        #{applicationConfiguration.piwikIdSite});
      var username = "#{identity.username}";
      if (#{identity.loggedIn} == false
    )
      {
        username = "anonymous";
      }
      piwikTracker.setCustomVariable(1, "Visit", username, "visit");
      piwikTracker.setCustomVariable(2, "View page", username, "page");

      piwikTracker.trackPageView();
      piwikTracker.enableLinkTracking();
    } catch (err) {
    }
    //]]>
    </script>
    <!-- End Piwik Code -->
  </s:fragment>

  <!--                                                                         -->
  <!-- This jQuery needs to import before assets/js/script.min.js (dependency) -->
  <!--                                                                         -->
  <script type="text/javascript"
    src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

  <script type="text/javascript"
    src="#{applicationConfiguration.webAssetsUrl}/assets/js/script.min.js"></script>

  <script type="text/javascript" src="#{request.contextPath}/resources/script/signals.min.js"/>
  <script type="text/javascript" src="#{request.contextPath}/resources/script/crossroads.min.js"/>
</f:view>
